#include"process.h"

void flushprocess(double current,double target)
{
	// 1.定义旋转状态
	const char* lable = "|/-\\";
	int len = strlen(lable);
	static int cnt = 0;
	// 2.定义字符数组
	char buf[NUM];
	memset(buf,'\0',sizeof(buf));
	// 3.打印当前进度
	double rate = (current * 100.00 / target) > 100.00 ? 100.00 :(current *100 / target);
	int num = (int)rate;
	for(int i = 0; i < num; i++)
	{
		buf[i] = STYLE;
	}  
	printf("[%-100s][%.1f%%][%c]\r",buf,rate,lable[cnt++ % len]);
	fflush(stdout);
}
